"use strict";
cc._RF.push(module, '598c0EY9y5Bq5T3/e8lrd7z', 'listPrefab');
// Script/listPrefab.js

"use strict";

cc.Class({
    extends: cc.Component,

    properties: {
        headSprite: cc.Node,
        leaveSprite: cc.Node,
        nameLabel: cc.Label,
        scoreLabel: cc.Label,
        userInfo: null,
        rankLabel: cc.Label

    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function onLoad() {},
    start: function start() {},
    init: function init(userDic) {
        console.log('信息', userDic);
        this.userInfo = userDic;
        this.scoreLabel.getComponent(cc.Label).string = this.userInfo["score"];
        this.nameLabel.getComponent(cc.Label).string = this.userInfo["name"];

        if (userDic["avatar"]) {
            var that = this;
            cc.loader.load({ url: userDic["avatar"], type: 'png' }, function (err, img) {

                var mylogo = new cc.SpriteFrame(img);

                that.headSprite.getComponent(cc.Sprite).spriteFrame = mylogo;

                that.headSprite.width = 82;

                that.headSprite.height = 82;
            });
        }

        var that = this;

        if (userDic["user_rank"] == 1) {
            console.log("第一名");
            var _this = that;
            cc.loader.loadRes("leave_1", cc.SpriteFrame, function (err, spriteFrame) {

                _this.leaveSprite.getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        } else if (userDic["user_rank"] == 2) {
            console.log("第2名");
            var _this2 = that;
            cc.loader.loadRes("leave_2", cc.SpriteFrame, function (err, spriteFrame) {

                _this2.leaveSprite.getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        } else if (userDic["user_rank"] == 3) {
            console.log("第3名");
            var _this3 = that;
            cc.loader.loadRes("leave_3", cc.SpriteFrame, function (err, spriteFrame) {

                _this3.leaveSprite.getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        } else {
            console.log("除前三名");
            var _this4 = that;
            that.rankLabel.node.active = true;
            that.rankLabel.getComponent(cc.Label).string = userDic["user_rank"];
            cc.loader.loadRes("排名底框", cc.SpriteFrame, function (err, spriteFrame) {

                _this4.leaveSprite.getComponent(cc.Sprite).spriteFrame = spriteFrame;
            });
        }
    }
});

cc._RF.pop();